package cn.yyh.servicePay.controller;

import cn.yyh.commons.exception.MyException;
import cn.yyh.commons.utils.GetTokenUtil;
import cn.yyh.commons.utils.R;
import cn.yyh.servicePay.service.IAlipayInfoService;
import cn.yyh.servicePay.service.IPayBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/servicePay/ali")
public class AlipayController {

    @Autowired
    private IPayBillService payBillService;

    @Autowired
    private IAlipayInfoService alipayInfoService;

    @PostMapping("/notify")
    public R aliPay(HttpServletRequest request) {
        try {
            payBillService.dealNotify(request);
            return R.oK();
        } catch (MyException e) {
            e.printStackTrace();
            return R.error().message(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return R.error().message("系统繁忙");
        }
    }

}
